From: Alexandre Emsenhuber Date: Sun, 18 Aug 2013 10:25:36 +0000 (+0200) Subject: Add new HTMLForm::addHiddenFields() methods X-Git-Tag: 1.31.0-rc.0~18925 X-Git-Url: http://git.cyclocoop.org/%28%5B%5E/404?a=commitdiff_plain;h=84f64b30fc8eff72bb4bbcddd79915ee189952d7;p=lhc%2Fweb%2Fwiklou.git Add new HTMLForm::addHiddenFields() methods Allows to set various hidden fields from a single method call; can be used with: $form->addHiddenFields( $context->getRequest()->getValues( /* field list */ ) ); Change-Id: I864584e5889297bb680808163f48795bab8f7afb --- diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index 84e7874d6e..ed9440ca15 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -574,6 +574,21 @@ class HTMLForm extends ContextSource { return $this; } + /** + * Add an array of hidden fields to the output + * + * @since 1.22 + * @param array $fields Associative array of fields to add; + * mapping names to their values + * @return HTMLForm $this for chaining calls + */ + public function addHiddenFields( array $fields ) { + foreach ( $fields as $name => $value ) { + $this->mHiddenFields[] = array( $value, array( 'name' => $name ) ); + } + return $this; + } + /** * Add a button to the form * @param string $name field name.